package com.ywk.wsClient;

import org.java_websocket.client.WebSocketClient;
import org.java_websocket.handshake.ServerHandshake;

import java.net.URI;

/**
 * @Author zbh
 * @Date 2023/5/4
 */
public class WSClient extends WebSocketClient{

    public WSClient(URI serverUri) {
        super(serverUri);
    }

    @Override
    public void onOpen(ServerHandshake serverHandshake) {
        System.out.println("客户端启动成功");
    }

    @Override
    public void onMessage(String message) {
        System.out.println("客户端接收信息："+message);
    }

    @Override
    public void onClose(int i, String s, boolean b) {
        System.out.println("客户端已关闭");
    }

    @Override
    public void onError(Exception e) {
        System.out.println("客户端报错信息：");
        e.printStackTrace();
    }
}
